<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\Curation;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class CurationController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {

        return Grid::make(new Curation(), function (Grid $grid) {
            $grid->actions(function (Grid\Displayers\Actions $actions) {
//                $actions->disableDelete();
//                $actions->disableEdit();
                $actions->disableQuickEdit();
                $actions->disableView();
            });
            $grid->column('curation_id','ID')->sortable();
            $grid->column('curation_title');
//            $grid->column('curation_content');
            $grid->column('curation_sort')->editable()->sortable();
            $grid->column('created_at');
            $grid->column('updated_at');
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('curation_id');
            });
        });
    }


    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Curation(), function (Form $form) {
            $form->display('curation_id','ID');
            $form->text('curation_title');
            $form->editor('curation_content');
//            $form->text('curation_content');
            $form->number('curation_sort');

            $form->display('created_at');
            $form->display('updated_at');
            $form->disableHeader();
            $form->footer(function ($footer) {

                // 去掉`重置`按钮
                //$footer->disableReset();

                // 去掉`提交`按钮
                //$footer->disableSubmit();

                // 去掉`查看`checkbox
                $footer->disableViewCheck();

                // 去掉`继续编辑`checkbox
                $footer->disableEditingCheck();

                // 去掉`继续创建`checkbox
                $footer->disableCreatingCheck();
            });
        });
    }
}
